import java.awt.event.ActionEvent;
import java.util.Random;

import javax.swing.JButton;


public class Storm extends SpeedModifier {
	
	private JButton march, takeShelter;
	private final double lightning = .001;
	Random rand;
	public Storm(MainCardPanel display, Party party) {
		super(display, party);
		march = new JButton("March onward.");
		takeShelter = new JButton("Take Shelter until it passes.");
		march.addActionListener(this);
		takeShelter.addActionListener(this);
		duration = 4;
		speedFactor = 0;
		rand = new Random();
		displayName = "Severe Storm";
		imageFilename = "storm.jpg";
	}

	@Override
	public int modifySpeed(int s) {
		return (int) (((double)s)*speedFactor);
	}

	@Override
	public void decay() {
		super.decay();
		if (dead)
			return;
		if (speedFactor!=0 && rand.nextDouble() < lightning)
			p.addRandomEvent(new Lightning(display, p));
		return;
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		super.actionPerformed(e);
		if (e.getSource()==march) {
			speedFactor = .3;
		}
		
	}

	@Override
	public JButton[] getResponseElements() {
		
		JButton[] ret = new JButton[2];
		ret[0] = takeShelter;
		ret[1] = march;
		return ret;
	}
	
	

}
